/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.loja.model.entity.compra;

import br.com.loja.model.entity.Switchable;
import br.com.loja.view.swing.model.FormField;
import br.com.loja.view.swing.model.IgnoreTableModel;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author David Luiz
 */
@Entity
@Table(name = "compra")
public class Compra implements Switchable, Serializable {

    public static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long idCompra;
    @Temporal(TemporalType.DATE)
    private Calendar dataCompra;
    private String fornecedor;
    private BigDecimal valor;
    private BigDecimal desconto;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "compra")
    private List<ItemCompra> itensCompra = new ArrayList<>();

    @FormField(visible = false)
    @IgnoreTableModel
    private boolean dead;

    public Compra() {
    }

    /**
     * @return the idCompra
     */
    public Long getIdCompra() {
        return idCompra;
    }

    /**
     * @param idCompra the idCompra to set
     */
    public void setIdCompra(Long idCompra) {
        this.idCompra = idCompra;
    }

    /**
     * @return the dataCompra
     */
    public Calendar getDataCompra() {
        return dataCompra;
    }

    /**
     * @param dataCompra the dataCompra to set
     */
    public void setDataCompra(Calendar dataCompra) {
        this.dataCompra = dataCompra;
    }

    /**
     * @return the fornecedor
     */
    public String getFornecedor() {
        return fornecedor;
    }

    /**
     * @param fornecedor the fornecedor to set
     */
    public void setFornecedor(String fornecedor) {
        this.fornecedor = fornecedor;
    }

    /**
     * @return the valor
     */
    public BigDecimal getValor() {
        return valor;
    }

    /**
     * @param valor the valor to set
     */
    public void setValor(BigDecimal valor) {
        this.valor = valor;
    }

    /**
     * @return the desconto
     */
    public BigDecimal getDesconto() {
        return desconto;
    }

    /**
     * @param desconto the desconto to set
     */
    public void setDesconto(BigDecimal desconto) {
        this.desconto = desconto;
    }

    /**
     * @return the itensCompra
     */
    public List<ItemCompra> getItensCompra() {
        return itensCompra;
    }

    /**
     * @param itensCompra the itensCompra to set
     */
    public void setItensCompra(List<ItemCompra> itensCompra) {
        this.itensCompra = itensCompra;
    }

    /**
     * @return the dead
     */
    public boolean isDead() {
        return dead;
    }

    /**
     * @param dead the dead to set
     */
    public void setDead(boolean dead) {
        this.dead = dead;
    }

}
